﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
using System.IO;

namespace PuanYonetimi
{
    static class Program
    {

        public static DevExpress.LookAndFeel.DefaultLookAndFeel look = new DevExpress.LookAndFeel.DefaultLookAndFeel();
        public static Sessions Session = null;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Session = Sessions.CreateSession;
            bool calisiyor;
            Mutex Mtx = new Mutex(true, "PuanYonetimi", out calisiyor);
            if (!calisiyor)
            {
                MessageBox.Show("Program çalışıyor.");
                return;
            }
            GC.KeepAlive(Mtx);
            DevExpress.UserSkins.BonusSkins.Register();
            look.LookAndFeel.SkinName = "Dark Side";
            DevExpress.Skins.SkinManager.EnableFormSkins();

            if (!File.Exists(Application.StartupPath + "\\ayarlar.ini"))
            {
                frmAyarlar ayar = new frmAyarlar();
                if (ayar.ShowDialog() == DialogResult.OK)
                    Application.Exit();
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                frmLogin login = new frmLogin();
                if (login.ShowDialog() == DialogResult.OK)
                {
                    if (login.AdminMode)
                        Application.Run(new frmMain());
                    else
                        Application.Run(new frmCekBaski());
                }
            }

            Session.CloseSession();
        }
    }
}
